package com.example.weatherforecast.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MyDatabaseHelper extends SQLiteOpenHelper {

    public MyDatabaseHelper(Context context) {
        super(context, "weather_forecast.db", null, 1);
    }

    /**
     * 数据库第一次创建时执行的方法
     * 创建一张weather_info表
     *
     * @param db
     */
    @Override
    public void onCreate(SQLiteDatabase db) {
        // 创建表sql语句
        String sql = "create table info(_id integer primary key autoincrement," +
                "city varchar(20) unique not null," +
                "content text not null)";
        // 执行创建表sql语句的操作
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
